function out = getAllControls(model,xAll_cu)

[nn,T] = size(xAll_cu);
if nn > T
    xAll_cu = xAll_cu';
    [nn,T] = size(xAll_cu);
end
ny  = size(model.g0,1);
nx  = model.nx;
y_cu = zeros(ny,T);
x_cu = zeros(nx,T);
if model.pruningOn == 1
    xf_cu  = xAll_cu(1:model.nx,:);
    if model.appOrder > 1
        xs_cu = zeros(model.nx,T);
        xs_cu(1:model.nx1,:) = xAll_cu(model.nx+1:model.nx+model.nx1,:);
    end
    if  model.appOrder > 2
        xrd_cu = zeros(model.nx,T);
        xrd_cu(1:model.nx1,:) = xAll_cu(model.nx+model.nx1+1:model.nx+2*model.nx1,:);
    end
    for t=1:T
        if model.appOrder == 1
            y_cu(:,t) = model.g0 + model.gx*xf_cu(:,t);
            x_cu(:,t) = xf_cu(:,t);
        elseif model.appOrder == 2
            AA_cu = kron3(xf_cu(:,t),xf_cu(:,t));
            y_cu(:,t) = model.g0 + model.gx*(xf_cu(:,t)+xs_cu(:,t)) + model.Gxx*AA_cu;
            x_cu(:,t) = xf_cu(:,t)+xs_cu(:,t);
        elseif model.appOrder == 3
            AA_cu = kron3(xf_cu(:,t),xf_cu(:,t));
            BB_cu = kron3(xs_cu(:,t),xf_cu(:,t));
            y_cu(:,t) = model.g0 + model.gx*(xf_cu(:,t)+xs_cu(:,t)+xrd_cu(:,t)) ...
                + model.Gxx*(AA_cu + 2*BB_cu) + model.Gxxx*kron3(AA_cu,xf_cu(:,t));
            x_cu(:,t) = xf_cu(:,t)+xs_cu(:,t)+xrd_cu(:,t);
        end
    end        
else
    for t=1:T
        y_cu(:,t) = model.g0 + model.gx*xAll_cu(:,t);
        if model.appOrder > 1
            AA_cu = kron3(xAll_cu(:,t),xAll_cu(:,t));
            y_cu(:,t) = y_cu(:,t) + model.Gxx*AA_cu;
        end
        if model.appOrder > 2
            y_cu(:,t) = y_cu(:,t) + model.Gxxx*kron3(AA_cu,xAll_cu(:,t));
        end
        x_cu = xAll_cu(:,t);
    end
end

out.y_cu = y_cu;
out.x_cu = x_cu;
if model.pruningOn == 1
    out.xAll_cu = xAll_cu;
end

end